﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Mail;

namespace Oplaco.Core.BusinessLogicLayer
{
    public sealed class Mail
    {


        public static void Send(int userid, string subject, string body)
        {
            MembersDB member = new MembersDB();
            member.Initialize(userid);
            
            MailMessage message = new MailMessage();
            SmtpClient smtpClient = new SmtpClient();
            try
            {
                message.To.Add(member.Email);
                message.Subject = subject;
                message.IsBodyHtml = true;
                message.Body = body;
                smtpClient.Send(message);
            }
            catch (Exception exception)
            {
                Oplaco.Exceptions.AppService.ProcessAndNotifyBusinessLayerException(exception);
            }

        }       

        public static void Send(string mailto, string subject, string body)
        {

            MailMessage message = new MailMessage();
            SmtpClient smtpClient = new SmtpClient();
            try
            {
                message.To.Add(mailto);
                message.Subject = subject;
                message.IsBodyHtml = true;
                message.Body = body;
                smtpClient.Send(message);
            }
            catch (Exception exception)
            {
                Oplaco.Exceptions.AppService.ProcessAndNotifyBusinessLayerException(exception);
            }
            
        }
    }
}
